package com.ror.java.se.io;

import java.io.*;

/*
    JDK9处理IOException：在合适的时机自动释放资源
        创建对象的语句写在外面，try的小括号中直接写变量名，用分号隔开
 */

public class Demo07IOEin9 {
    public static void main(String[] args) throws FileNotFoundException {
        File src = new File("assets/io/byte/ryuko.png");
        File dest = new File("assets/io/byte/copy.png");
        FileInputStream fi = new FileInputStream(src);
        FileOutputStream fo = new FileOutputStream(dest);
        try (fi;fo) {
            int b;
            while ((b = fi.read()) != -1) {
                fo.write(b);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
